using System.Collections.Generic;
using UnityEngine;

public class DevConsoleAchievementsScroll : MonoBehaviour
{
	public GameObject achievementPrefab;

	public GameObject grid;

	private bool firstCall = true;

	private void OnEnable()
	{
		if (firstCall)
		{
			firstCall = false;
			grid.transform.DestroyChildren();
			foreach (Achievement allAchievement in AchievementsManager.instanse.allAchievements)
			{
				DevConsoleAchievement component = NGUITools.AddChild(grid, achievementPrefab).GetComponent<DevConsoleAchievement>();
				component.Init(allAchievement);
			}
		}
		else
		{
			foreach (Transform item in grid.transform)
			{
				item.gameObject.GetComponent<DevConsoleAchievement>().Refresh();
			}
		}
		List<EventDelegate> onClick = grid.transform.GetChild(0).gameObject.GetComponent<UIButton>().onClick;
		foreach (EventDelegate item2 in onClick)
		{
			item2.Execute();
		}
	}
}
